package com.wj.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;
import java.util.stream.Stream;

/**
 *  品牌分类枚举
 */
@Getter
@AllArgsConstructor
public enum BrandCategory {

    BRAND_A("2001","品牌A"),
    BRAND_B("2002","品牌B"),
    BRAND_C("2003","品牌C"),
    BRAND_D("2004","品牌D"),
    BRAND_E("2005","品牌E");

    // 品牌分类编码
    private final String code;

    //品牌分类描述信息
    private final String description;


    public static BrandCategory of(String code){
        Objects.requireNonNull(code);

        return Stream.of(values())
                .filter(bean -> bean.code.equals(code))
                .findAny()
                .orElseThrow(
                        () -> new IllegalArgumentException(code + "not exists")
                );
    }
}
